import React from 'react';
import { Main } from './myhome/Main';
import { Consult } from './myhome/Consult';
import { Ready } from './myhome/Ready';
import { Reply } from './myhome/Reply';
import { Report } from './myhome/Report';
import { NavBar, Icon,TabBar } from 'antd-mobile';
import { authPromise }from '../api/user';
import {
    Route,
    withRouter,
    Redirect
} from 'react-router-dom';

import '../style/component/Home.less';
class Myhome extends React.Component{
    constructor(props){
        super(props)
        this.state = {
            selectedTab:'main'
        }
        //this.handleTabSelected = this.handleTabSelected.bind(this)
    }
    //生命周期函数，组件第一次被渲染到Dom中，mount(挂载)
    componentDidMount() {
        // authPromise().then((res)=>{
        //     console.log(res);
        //     console.log("enen>>>>????",this.props)
        // })
    }
    handleTabSelected(value){   
        this.setState({'selectedTab': value})
        console.log("shenmm",this.props)
    }
    render(){
        return(
                <div className="homePage">
                    {/* <NavBar
                        mode="light"
                        // icon={<Icon type="left" />}
                        onLeftClick={() => this.props.history.push('/')}
                        >
                        浙有数
                    </NavBar> */}
                    {/* <div class="content">
                        <Route path={`${this.props.match.url}/left`}  component={Demo} />
                        <Route path={`${this.props.match.url}/middle`}  component={Index} />
                        <Route path={`${this.props.match.url}/right`}  component={Right} />
                    </div> */}
                    <TabBar
                        unselectedTintColor="#949494"
                        tintColor="#33A3F4"
                        barTintColor="#EAEAEA"
                        tabBarPosition="bottom"
                    >
                        <TabBar.Item
                            title="首页"
                            key="main"
                            selected={this.state.selectedTab === 'main'}
                            onPress={this.handleTabSelected.bind(this,'main')}
                            icon={<i className='iconfont iconshouye tabIconfont'></i>}
                            selectedIcon={<i className='iconfont iconshouye tabIconfont'></i>}
                        >
                            <Main></Main>
                        </TabBar.Item>
                        <TabBar.Item
                            title="待办"
                            key="ready"
                            selected={this.state.selectedTab === 'ready'}
                            onPress={this.handleTabSelected.bind(this,'ready')}
                            icon={<i className='iconfont icondaiban tabIconfont'></i>}
                            selectedIcon={<i className='iconfont icondaiban tabIconfont'></i>}
                        >
                           <Ready></Ready>
                        </TabBar.Item>
                        <TabBar.Item
                            title="报表"
                            key="report"
                            selected={this.state.selectedTab === 'report'}
                            onPress={this.handleTabSelected.bind(this,'report')}
                            icon={<i className='iconfont iconbaobiaozhongxin tabIconfont'></i>}
                            selectedIcon={<i className='iconfont iconbaobiaozhongxin tabIconfont'></i>}
                        >
                           <Report></Report>
                        </TabBar.Item>
                        <TabBar.Item
                            title="反馈"
                            key="reply"
                            selected={this.state.selectedTab === 'reply'}
                            onPress={this.handleTabSelected.bind(this,'reply')}
                            icon={<i className='iconfont iconyaoqingdaoshi tabIconfont'></i>}
                            selectedIcon={<i className='iconfont iconyaoqingdaoshi tabIconfont'></i>}
                        >
                            <Reply></Reply>
                        </TabBar.Item>
                        <TabBar.Item
                            title="咨询"
                            key="consult"
                            selected={this.state.selectedTab === 'consult'}
                            onPress={this.handleTabSelected.bind(this,'consult')}
                            icon={<i className='iconfont iconzixun tabIconfont'></i>}
                            selectedIcon={<i className='iconfont iconzixun tabIconfont'></i>}
                        >
                            <Consult></Consult>
                        </TabBar.Item>
                    </TabBar>
                </div>
        )
    }
}


export default withRouter(Myhome);